package com.roocon.design_pattern.chapter04_future_design;

public class AsynFuture<T> implements Future<T> {

  private volatile boolean done = false;

  // 返回结果
  private T result ;

  public void done(T result){
    synchronized (this) {
      this.result = result;
      this.done = true;
      this.notify();
    }
  }

  @Override public T get() throws InterruptedException {
    synchronized (this) {
      while (!done) {
        this.wait();
      }
    }
    return result;
  }
}
